package com.yanzhu.bean;

import com.yanzhu.constant.ExceptionEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author: 方炎柱
 * @Description:
 * @Date: Created in 15:55 2017/12/25
 * @Modified:
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseBean {
    private int code;

    private String message;

    private Object data;

    public ResponseBean(int code, String message){
        this.code = code;
        this.message = message;
    }

    public ResponseBean(ExceptionEnum exceptionEnum){
        this.code = exceptionEnum.getCode();
        this.message = exceptionEnum.getMessage();
    }

    /**
     * 成功
     */
    public static ResponseBean ok(){
        return new ResponseBean(0, "success");
    }

    /**
     * 成功
     */
    public static ResponseBean ok(Object object){
        return new ResponseBean(0, "success", object);
    }

    public static ResponseBean fail(Object object){
        return new ResponseBean(-1, "fail", object);
    }
}
